<template>
	<view class="" >
		<van-card
		  	  :num= "orderDetail.participant"
		  	  :price= "orderDetail.totalMoney"
		  	  :desc= "orderDetail.payment"
		  	  :title= "orderDetail.status"
		  thumb="https://t7.baidu.com/it/u=2471051649,2314656574&fm=193&f=GIF"
		>
		</van-card>
			<van-cell title="售价" :value="orderDetail.participant" />
			<van-cell title="优惠" value="0" />
			<van-cell title="报名信息" :value="orderDetail.participant" />
			<van-cell title="付款说明" is-link bind:click="showPopup" />
			<van-cell title="退款说明" value="" :label="orderDetail.payment" border="true" />
			<van-cell  style = "float: left;" title="付款倒计时："   />
			<van-count-down :time="time" style = "float: right; padding-top: 30rpx;" />
			<van-button color="linear-gradient(to right, #4bb0ff, #6149f6)"  @click = "onSubmit()" :disabled ="button">
			  立即支付
			</van-button>

	</view>

</template>

<script>
	export default {
		data() {
			return {
				active: "全部",
				time: 30 * 60 * 60 * 1000,
				button: true,
				orderDetail: {
					orderNo: '',
					totalMoney: '',
					status: '',
					participant: '',
					payment: '',
					status: ''
				},
				onSubmit() {
					console.log(this.orderDetail.orderNo)
					this.payOrder(this.orderDetail.orderNo)
				},
				payOrder(orderNo){
					console.log("orderNo",orderNo)
					uni.request({
						url: 'http://localhost:8086/alipay/appPay', //仅为示例，并非真实接口地址。
						data: {
							orderNo: orderNo
						},
						success: (res) => {
								
							if(res.data.data>0){
								uni.showToast({
									title: '成功支付！',
									icon: 'none',
								})		
								uni.navigateTo({
									url: "/pages/order/detail"
								})
							}else{
								uni.showToast({
									title: '支付失败！',
									icon: 'none',
								})	
							}

							
						}
					});
				},
				getOrderByNo(orderNo){
					console.log("orderNo",orderNo)
					uni.request({
						url: 'http://localhost:8086/order/findOrder', //仅为示例，并非真实接口地址。
						data: {
							orderNo: orderNo
						},
						success: (res) => {
							console.log(res.data);
							var order=res.data.data;
							if(order.status === "待支付"){
								this.button = false
							}
							this.orderDetail.orderNo=order.orderNo
							this.orderDetail.participant=order.participant
							this.orderDetail.payment=order.payment
							this.orderDetail.status=order.detail
							console.log(order.totalMoney)
							this.orderDetail.totalMoney=order.totalMoney
							
						}
					});
				}
			}
		},
		methods: {
			changeMsg(e) {
				console.log("加载方法了")
			},
		},
		onLoad(options) {
			console.log(options.orderNo); 
			this.getOrderByNo(options.orderNo)
		}
	}
</script>

<style>
</style>
